home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / dbf_tc.zip / D_PUTREC.C < prev    next >
Text File  |  1987-06-06  |  1KB  |  39 lines

  1. /* 
  2. **        file:        d_putrec.c
  3. **        purpose:    routine to update a record in a dbiii file.
  4. **        ussage:    d = (struct DBF *)malloc(sizeof(struct DBF));
  5. **                    strcpy(d->filename,"filename.dbf");
  6. **                    d_open(d);
  7. **                    d_getrec(d,(long)recordno);
  8. **                    ... modify record ...
  9. **                    d_putrec(d,(long)recordno);
  10. **                    d_close(d);
  11. **                    free(d);
  12. **        notes:    the data for the record is contained in memory at the location
  13. **                    pointed to by DBF.record_ptr.
  14. **                    compile with "tcc -c d_putrec".    include this file in dbf.li
  15. **                    see dbf.h for structure of DBF
  16. **        returns:    0                    if successfull
  17. **                    RECNO_TOO_BIG    if record is not in database
  18. **        author:    Mark Sadler
  19. **        revised:    6/6/87
  20. */ 
  21.  
  22. #include <stdio.h>
  23. #include "dbf.h"
  24.  
  25. int d_putrec(struct DBF *d,unsigned long int r)
  26. {
  27.     if(r > d->records)
  28.         return(RECNO_TOO_BIG);
  29.     if(r > 0L)
  30.         {
  31.         fseek(d->file_ptr,((long)d->header_length + ((r - 1) * d->record_length)),0);
  32.         fwrite(d->record_ptr,d->record_length,1,d->file_ptr);
  33.         d->status = updated;
  34.         }
  35.     d->current_record = r;
  36.     return(0);
  37. }
  38.  
  39.